package ru.ifmo.rybakov.muclumon.analysis2;

import java.util.Map;

public class FunctionReverse extends Function {

	private String variableName;
	
	public FunctionReverse(String variableName) {
		this.variableName = variableName;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Double getValue(Map input) {
		Object o = input.get(variableName);
		if (o == null) {
			throw new RuntimeException("No variable found in input for name '" + variableName + "'");
		}
		Double d = (Double) o;
		return 1 / (Math.log(d));
	}

	@Override
	public Function[] getFunctions() {
		return new Function[] { this };
	}

	public String toString() {
		return "(1/ln(" + variableName + "))";
	}
}
